import request from 'umi-request';

export async function queryRule(params = {}) {
  return request('/api/member/api-member/member/list', {
    method: 'get',
    params: {
      pageNum: params.current,
      pageSize: params.pageSize,
      keyword: params.keyword,
    },
  }).then((res) => {
    if (res.flag) {
      const data = res.data;
      return {
        current: data.currPage,
        data: data.list,
        pageSize: data.pageSize,
        success: true,
        total: data.totalCount,
      };
    } else {
      return {};
    }
  });
}

export async function addInfo(params) {
  return request('/api/member/api-member/member/saveMainInfo', {
    method: 'POST',
    data: {
      ...params,
    },
  }).then((res) => {
    return res.flag;
  });
}

export async function updateInfo(params) {
  return request('/api/member/api-member/member/updateMainInfo', {
    method: 'POST',
    data: {
      ...params,
    },
  }).then((res) => {
    return res.flag;
  });
}

export async function getEmployeeById(id) {
  return request(`/api/member/api-member/member/getEmployeeById/${id}`, {
    method: 'get',
  });
}

export async function getSelfHelpById() {
  return request(`/api/member/api-member/selfHelp/getEmployeeById`, {
    method: 'get',
  });
}

export async function updateMainInfo(params) {
  return request('/api/member/api-member/member/updateMainInfo', {
    method: 'POST',
    data: params,
  });
}

export async function deleteEmployeeById(id) {
  return request(`/api/member/api-member/member/deleteMainInfo/${id}`, {
    method: 'get',
  });
}


export async function getEducationInfo(id) {
  return request(`/api/member/api-member/member/getEduByOid/${id}`, {
    method: 'get',
  }).then((res) => {
    return res.data;
  });
}

export async function addEducationInfo(params) {
  return request('/api/member/api-member/member/saveEducationInfo', {
    method: 'POST',
    data: params,
  });
}

export async function updateEducationInfo(params) {
  return request('/api/member/api-member/member/updateEducationInfo', {
    method: 'POST',
    data: params,
  });
}

export async function deleteEducationInfo(id) {
  return request(`/api/member/api-member/member/deleteEducation/${id}`, {
    method: 'get',
  }).then((res) => {
    return res.data;
  });
}

export async function getSocietyInfo(id) {
  return request(`/api/member/api-member/member/getSocietyInfo/${id}`, {
    method: 'get',
  }).then((res) => {
    return res.data;
  });
}

export async function addSocietyInfo(params) {
  return request('/api/member/api-member/member/saveSociety', {
    method: 'POST',
    data: params,
  });
}

export async function updateSocietyInfo(params) {
  return request('/api/member/api-member/member/updateSociety', {
    method: 'POST',
    data: params,
  });
}

export async function deleteSocietyInfo(id) {
  return request(`/api/member/api-member/member/deleteSociety/${id}`, {
    method: 'get',
  }).then((res) => {
    return res.data;
  });
}

export async function getFamilyInfo(id) {
  return request(`/api/member/api-member/member/getFamilyListByOid/${id}`, {
    method: 'get',
  }).then((res) => {
    return res.data;
  });
}

export async function addFamilyInfo(params) {
  return request('/api/member/api-member/member/saveFamily', {
    method: 'POST',
    data: params,
  });
}

export async function updateFamilyInfo(params) {
  return request('/api/member/api-member/member/updateFamily', {
    method: 'POST',
    data: params,
  });
}

export async function deleteFamilyInfo(id) {
  return request(`/api/member/api-member/member/deleteFamily/${id}`, {
    method: 'get',
  }).then((res) => {
    return res.data;
  });
}

export async function getInorgInfo(id) {
  return request(`/api/member/api-member/member/getInorgInfo/${id}`, {
    method: 'get',
  }).then((res) => {
    return res.data;
  });
}

export async function addInorgInfo(params) {
  return request('/api/member/api-member/member/saveInorgInfo', {
    method: 'POST',
    data: params,
  });
}

export async function updateInorgInfo(params) {
  return request('/api/member/api-member/member/updateInorgInfo', {
    method: 'POST',
    data: params,
  });
}

export async function deleteInorgInfo(id) {
  return request(`/api/member/api-member/member/deleteInorg/${id}`, {
    method: 'get',
  }).then((res) => {
    return res.data;
  });
}

export async function getJobByOrgId(id) {
  return request(`/api/member/api-member/job/findJobByOrgId/${id}`, {
    method: 'get'
  }).then((res) => {
    return res.data;
  });
}

export async function getBaseOptions() {
  return request(`/api/member/api-member/job/getBaseItem`, {
    method: 'get',
  }).then((res) => {
    return res.data;
  });
}

export async function getNativeplace() {
  return request(`/api/member/api-member/job/getNativeplace`, {
    method: 'get',
  }).then((res) => {
    return res.data;
  });
}

export async function updateHireDate(oid,date) {
  return request('/api/member/api-member/userUpdateInfo/saveUserUpdateHiredateInfo', {
    method: 'POST',
    data: {
      oid:oid,
      hiredate:date
    },
    requestType: "form"
  });
}

export async function findDictionary(code) {
  return request(`/api/member/api-member/neusoft/findDictionary`, {
    method: 'get',
    params: {
      typeCode:code
    }
  }).then((res) => {
    return res.data;
  });
}

